<?php
final class GuestBookView {
	private $GuestBookItems = array ();
	private $GuestBookItems = array ();

	public function AddGuestBookItem ($title, $pubDate, $description) {
		$GuestBookItem = new GuestBookItem ($title, $pubDate, $description);
		array_push ($this->GuestBookItems, $GuestBookItem);
	}

	public function Create () {
		$root = new DOMDocument ('1.0', 'utf-8');
		$root->formatOutput = true;
		$CyberMedia = $root->createElement ('CyberMedia');
		$version = $root->createAttribute ('version');
			$text = $root->createTextNode ('2.0');
		$version->appendChild ($text);
		$CyberMedia->appendChild ($version);

		$Items = $root->createElement ('Items');

		foreach ($this->GuestBookItems as $GuestBookItem) {
			$Items->CreateElement ($root, $GuestBookItem);
		}

		$CyberMedia->appendChild ($items);
		$root->appendChild ($CyberMedia);
		return $root->saveXML ();
	}

}
?>